# Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
# Maintainer: Aiden Grossman <agrossman154@yahoo.com>
pkgname=vtk
pkgver=9.1.0
pkgrel=6
pkgdesc="A software system for 3D computer graphics, image processing and visualization"
url="https://vtk.org/"
# s390x blocked by netcdf
arch="all !s390x"
license="BSD-3-Clause"
depends_dev="
	boost-dev
	doxygen
	ffmpeg-dev
	gdal-dev
	glew-dev
	jpeg-dev
	libexecinfo-dev
	libpng-dev
	libxml2-dev
	openmpi-dev
	pdal-dev
	qt5-qtbase-dev
	qt5-qttools-dev
	qt5-qtx11extras-dev
	sqlite-dev
	tk-dev
	unixodbc-dev
	zlib-dev
	netcdf-dev
	hdf5-dev
	curl-dev
	"
makedepends="$depends_dev
	cmake
	samurai
	"
checkdepends="
	xvfb-run
	mesa
	mesa-dri-gallium
	"
subpackages="$pkgname-doc $pkgname-dev"
source="
	https://www.vtk.org/files/release/${pkgver%.*}/VTK-$pkgver.tar.gz
	https://www.vtk.org/files/release/${pkgver%.*}/VTKData-$pkgver.tar.gz
	https://www.vtk.org/files/release/${pkgver%.*}/VTKLargeData-$pkgver.tar.gz
	ffmpeg5.patch
	fix-build.patch
	fix-allvalues.patch
	unistd.patch
	disable-tests.patch
	"
builddir="$srcdir/VTK-$pkgver"

build() {
	cmake -B build -G Ninja \
		-Wno-dev \
		-DCMAKE_SKIP_INSTALL_RPATH=ON \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DModule_vtkIOPDAL=ON \
		-DVTK_USE_LARGE_DATA=ON \
		-DVTK_PYTHON_VERSION="3" \
		-DVTK_CUSTOM_LIBRARY_SUFFIX="" \
		-DCMAKE_BUILD_TYPE=Release \
		-DVTK_MODULE_USE_EXTERNAL_VTK_hdf5=ON \
		-DVTK_MODULE_USE_EXTERNAL_VTK_netcdf=ON \
		-DVTK_BUILD_TESTING=ON
	cmake --build build
}

check() {
	xvfb-run ctest -a -j $JOBS --test-dir ./build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
b2c4be8795fa082e0776e6ffdb9a3fd88dbb235841a8369a34ebe26cf4c5fcb1610fcca987be314510629da3edc74ee76c0ce2cc88d5ef4b099ac550ac892b0a  VTK-9.1.0.tar.gz
134a8dd2b029d3a4959b601987e68a0caa5d050532655b6786b5b67dfc77d3639628b2b957511f8998e63864c247c501a11a6aed248c762f13e860d878778e1a  VTKData-9.1.0.tar.gz
0760dfd4e92bbfec10fec9d783f548a8ca5464b1a1744dfa575d4ed4592756335dbfcf28249d2da964aa6b41933ff1ac98458e4a32484ee4bb91b5e7cfaa78c9  VTKLargeData-9.1.0.tar.gz
df9e44c97333457d5090dddd0701c7e1222cc8c739d628d5495ae5a312adb73f53f22a6d6ccfbed69a85ea3c350dc98aafc0d2482b0a91faa3cd2a127b2d1dc7  ffmpeg5.patch
c814628a7ce9e1015cb02d4c9ad7ae7c6ad6d5d83b553f0c484414744488e4d0fa313924b4fd0f579a363352832347035147d1be3aca6f6a4885b6f9a1590b9e  fix-build.patch
87ffb0f1a243a10983e0313b3ca472361c74f0f5054be0eca898232f11a57369dfba80a836679a772eb641e1fdd43fa07ae7f85faecf3243b172c4206325dd9d  fix-allvalues.patch
4054796e7f4cf78be3fbdf4d0befb79ff118e9a54e649da8a39b717e84ccb3d9dc05d8398de046447f789df5a8f3f84253866f3e59f7cbacfe981ffbbe5b7429  unistd.patch
da077b2097024ed370b3fd4d73ea6e0b75a9e17e7ed914ae55c59109c59f388f250ff9efdf19f55fb54120306b49d6be2e8740147a0558d04fc36fcc3da9d817  disable-tests.patch
"
